package com.sporadic.desk.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.additional.query.impl.QueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sporadic.desk.dao.UserCouponDao;
import com.sporadic.desk.pojo.UserCoupon;
import com.sporadic.desk.service.UserCouponService;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

/**
 * @program: sporadic
 * @description:
 * @author: LHD   QQ:1727865856
 * @create: 2019-12-04 11:07
 **/
@Service
public class UserCouponServiceImpl extends ServiceImpl<UserCouponDao, UserCoupon> implements UserCouponService {

    @Override
    public boolean updateUserCoupon(Integer couponId) {
        UserCoupon userCoupon = getById(couponId);
        userCoupon.setUcStatus(2);
        try {
            super.update(userCoupon, new QueryWrapper<UserCoupon>()
                    .eq("uc_id", couponId));
            return true;
        }catch (Exception e){
            throw new RuntimeException("对不起，优惠券不可用!");
        }
    }
}
